<?php
/**
 * Created by PhpStorm.
 * User: figo-009
 * Date: 2017/5/17
 * Time: 17:00
 */
namespace ApigilityGroup\DoctrineEntity;

use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Table;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\OneToOne;
use Doctrine\ORM\Mapping\JoinColumn;
use Doctrine\ORM\Mapping\JoinTable;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\ManyToMany;
use Doctrine\ORM\Mapping\OneToMany;
use Doctrine\Common\Collections\ArrayCollection;
use ApigilityVIP\DoctrineEntity\Service;

/**
 * Class Group
 * @package ApigilityGroup\DoctrineEntity
 * @Entity @Table(name="apigilitygroup_group")
 */
class Group
{
    /**
     * @Id @Column(type="integer")
     * @GeneratedValue
     */
    protected $id;

    /**
     *
     *
     * @Column(type="string", length=64, nullable=true)
     */
    protected $groupname;

    /**
     * 创建时间
     *
     * @Column(type="datetime", nullable=false)
     */
    protected $createtime;

    /**
     * 男参团数
     *
     * @Column(type="integer", options={"default"=0}, nullable=true)
     */
    protected $male_participation_nums;
    
    /**
     * 女参团数
     *
     * @Column(type="integer", options={"default"=0}, nullable=true)
     */
    protected $female_participation_nums;
    
    /**
     * 男免费参团人数
     *
     * @Column(type="integer", options={"default"=0}, nullable=true)
     */
    protected $male_free_participation_nums;
    
    /**
     * 女免费参团人数
     *
     * @Column(type="integer", options={"default"=0}, nullable=true)
     */
    protected $female_free_participation_nums;
    
    /**
     * 团购号
     *
     * @Column(type="string", length=64, nullable=false)
     */
    protected $buy_number;
    
    /**
     * 团的创建者
     *
     * @ManyToOne(targetEntity="ApigilityUser\DoctrineEntity\User")
     * @JoinColumn(name="create_user_id", referencedColumnName="id")
     */
    protected $user;
    
    /**
     * 团基本设定
     *
     * @ManyToOne(targetEntity="ApigilityGroup\DoctrineEntity\Setting")
     * @JoinColumn(name="setting_id", referencedColumnName="id")
     */
    protected $group_setting;

    /**
     * Many Users have many Users.
     * @ManyToMany(targetEntity="ApigilityVIP\DoctrineEntity\Service", inversedBy="services")
     * @JoinTable(name="apigilitygroup_group_has_service",
     *      joinColumns={@JoinColumn(name="group_id", referencedColumnName="id")},
     *      inverseJoinColumns={@JoinColumn(name="service_id", referencedColumnName="id")}
     *      )
     */
    protected $services;

    public function __construct()
    {
        $this->user = new ArrayCollection();
        $this->group_setting = new ArrayCollection();
        $this->services = new ArrayCollection();
    }
    
    public function getId()
    {
        return $this->id;
    }

    public function setId($id)
    {
        $this->id = $id;
    }

    public function getCreatetime()
    {
        return $this->createtime;
    }

    public function setCreatetime($createtime)
    {
        $this->createtime = $createtime;
    }

    public function getMaleParticipationNums()
    {
        return $this->male_participation_nums;
    }

    public function setMaleParticipationNums($male_participation_nums)
    {
        $this->male_participation_nums = $male_participation_nums;
    }

    public function getFemaleParticipationNums()
    {
        return $this->female_participation_nums;
    }

    public function setFemaleParticipationNums($female_participation_nums)
    {
        $this->female_participation_nums = $female_participation_nums;
    }

    public function getMaleFreeParticipationNums()
    {
        return $this->male_free_participation_nums;
    }

    public function setMaleFreeParticipationNums($male_free_participation_nums)
    {
        $this->male_free_participation_nums = $male_free_participation_nums;
    }

    public function getFemaleFreeParticipationNums()
    {
        return $this->female_free_participation_nums;
    }

    public function setFemaleFreeParticipationNums($female_free_participation_nums)
    {
        $this->female_free_participation_nums = $female_free_participation_nums;
    }

    public function getBuyNumber()
    {
        return $this->buy_number;
    }

    public function setBuyNumber($buy_number)
    {
        $this->buy_number = $buy_number;
    }

    public function getUser()
    {
        return $this->user;
    }

    public function setUser($user)
    {
        $this->user = $user;
    }

    public function getGroupSetting()
    {
        return $this->group_setting;
    }

    public function setGroupSetting($group_setting)
    {
        $this->group_setting = $group_setting;
    }

    public function getServices()
    {
        return $this->services;
    }

    public function setServices($services)
    {
        $this->services = $services;
    }



    public function addService(Service $service)
    {
        $this->services[] = $service;
        return $this;
    }

    public function getGroupname()
    {
        return $this->groupname;
    }

    public function setGroupname($groupname)
    {
        $this->groupname = $groupname;
    }

}